package com.itheima.ZuoYe;

import java.util.Scanner;

class Worker1 {

    private String name;
    private int year;

    public Worker1() {

    }

    public Worker1(String name, int age) {
        this.name = name;
        this.year = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }
}
    public  class Worker {

        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入工人姓名：");
            String name = sc.nextLine();
            System.out.println("请输入工人工龄：");
            int year = sc.nextInt();
            Worker1 w = new Worker1(name, year);
            System.out.println("该工人对象的信息如下：");
            System.out.println("姓名：" + w.getName());
            System.out.println("工龄：" + w.getYear());
        }
    }
